/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ysw.action;

import com.opensymphony.xwork2.ActionSupport;
import ysw.vo.Receive;
import static com.opensymphony.xwork2.Action.NONE;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import ysw.jdbc.ReceiveJdbc;
/**
 *
 * @author Administrator
 */
public class ReceiveAction extends ActionSupport {
    private Receive receive;

    public Receive getReceive()  {
        return receive;
    }

    public void setReceive(Receive receive) {
        this.receive = receive;
    }
    private List<Receive> receiveList;
    public String execute() throws Exception{
        ReceiveJdbc receiveJ=new ReceiveJdbc();
        
        receive.setEid(receive.getEid());
        receive.setEname(receive.getEname());
         receive.setEphone(receive.getEphone());
       
        receive.setCarnumber(receive.getCarnumber());
         receive.setRtime(receive.getRtime());
        receive.setJieche(receive.getJieche());
  
            
     
       receiveJ.addReceive(receive);
        return SUCCESS;
    }
    

public String showAllReceive(){
     
	   Receive receive=new Receive();
         ReceiveJdbc receiveJ=new ReceiveJdbc();
 
        try{
            receiveList=receiveJ.showReceive();
        }catch(SQLException e){
            e.printStackTrace();
        }
     
		Map request=(Map)ActionContext.getContext().get("request");
        request.put("receiveList",receiveList);
        return SUCCESS;
    }

public String showOneReceive() throws Exception{
          Receive receive1=new Receive();
         ReceiveJdbc receiveJ=new ReceiveJdbc();
         receive1=receiveJ.showOneReceive(receive.getId());
  Map request=(Map)ActionContext.getContext().get("request");
request.put("receive1",receive1);
return SUCCESS;
}

public String updateSaveReceive() throws Exception{
     ReceiveJdbc receiveJ=new ReceiveJdbc();
     receive.setId(receive.getId());
      receive.setEid(receive.getEid());
      receive.setEname(receive.getEname());
      receive.setEphone(receive.getEphone());
       
        receive.setCarnumber(receive.getCarnumber());
         receive.setRtime(receive.getRtime());
        receive.setJieche(receive.getJieche());
     
            receiveJ.updateSaveReceive(receive);
    return SUCCESS;
}
 
}
